% CREATE TARGET PATHS INCLUDING OCCLUDER POSITION FOR PLOTTING

msPerCycle = round((1000/60)*FpC);

a = 1;
for t = 1:3*msPerCycle + 1
    target22.time(t,1) = t - 1;
    % calculate cos function of x and multiply by no of pixels in half of
    % the stimulus path (0.5 x 0.75 x scnw)
    target22.X(t,1) = (0.5*0.75*scnw)*cos(((t-1)*60)/(FpC*1000)*2*pi);
    % calculate when occluder is present
    if -(scnw/(10/3)) < target22.X(t,1) && target22.X(t,1) < 0
        target22.occluder(t,1) = 1;
    else 
        target22.occluder(t,1) = 0;
    end
    % convert to logical
    target22.occluder = target22.occluder==1 ;
end

% tabulate x and y values of occluder for patch plotting later
for t = 1:3*msPerCycle
    if target22.occluder(t+1,1) == 1 && target22.occluder(t,1) == 0
        target22.plotocc.x(a,1) = t + 1;
        target22.plotocc.x(a,4) = t + 1;
    end
    if target22.occluder(t+1,1) == 0 && target22.occluder(t,1) == 1
        target22.plotocc.x(a,2) = t;
        target22.plotocc.x(a,3) = t;
        a = a + 1;
    end    
end

n_occluders = a - 1;         % number of occluders in 3 cycles (i.e. 6)

target22.plotocc.y(1:a-1,1:2) = -600;
target22.plotocc.y(1:a-1,3:4) = 600;
target22.plotocc.yvel(1:a-1,1:2) = -40;
target22.plotocc.yvel(1:a-1,3:4) = 40;

target22.one = target22.X(1:msPerCycle,1);

% CALCULATE TARGET VELOCITIES

target22.Xvel = velocity(target22.X,5,scnw,scnwcm,view_dist);

target22.onevel = target22.Xvel(1:msPerCycle,1);